﻿using UnityEngine;
using System.Collections;
using System;
namespace UEngine
{
    public class StringHelper
    {
        public static bool IsValidString(string value)
        {
            if ((value == null) || (value.Length == 0))
                return false;
            return true;
        }

        public static bool StringCompare(string value1, string value2)
        {
            if (!IsValidString(value1) || !IsValidString(value2))
                return false;
            return value1.Equals(value2);
        }

        public static bool String2Int32(string inValue, ref int outValue)
        {
            bool result = false;

            int tempValue = 0;
            if (!IsValidString(inValue))
            {
                return result;
            }

            try
            {
                tempValue = Convert.ToInt32(inValue);
                outValue = tempValue;
                result = true;

            }
            catch (Exception e)
            {
                Debug.Log(e.Message);
                result = false;
            }

            return result;
        }

    }    
}

